window.addEventListener('load', function () {
    //判定用户信息
    (function () {
        let li = document.querySelector('.xtx_navs li:first-child');
        let li2 = li.nextElementSibling;
        console.log(li2);
        function render() {
            if (localStorage.getItem('uname')) {
                li.innerHTML = `<a href="javascript:;"><i class="iconfont icon-user">${localStorage.getItem('uname')}</i></a>`;
                li2.innerHTML = `<a href="javascript:;">退出登录</a>`
            }
            else {
                li.innerHTML = `<a href="./login.html">请先登录</a>`;
                li2.innerHTML = `<a href="./register.html">免费注册</a>`
            }
        }
        render();
        li2.addEventListener('click', function () {
            localStorage.removeItem('uname');
            render();
        })
    })()
})